<{include file="Common/head"}>
<{include file="Common/menu" }>

<link href="_index_/yy/laydate.css" rel="stylesheet">
<script src="_index_/yy/laydate.js"></script>
<script type="text/javascript" src="_index_/laydate/laydate.js"></script>

<style type="text/css">
    .Hui-article-box{margin-left: 5px!important;margin-right: 5px!important;}
    #mytable td{text-align: center}

    .select_date{  width: 20%;  float: left;  }
    .search_tiaojian{width:40%;float: left}
    .order_con{    width: 100%;  height: 250px;  background: #c2ccd1;  float: left;margin-top: 10px;}
    .order_con h4{margin-top:0!important;}
    .display{display: none;}
    .order_table{}
    .order_table .check-box label{display: block;margin-top:3px;}
    .sub_order{position: relative;  top: 10px;  left: 20px;}
    #tab_demo{width: 100%;display: block;float: left;}
    .colorred{color:red;}
    .device_w{width:30%;height: 30px;}
    table.paibantable tr td{font-size: 18px;}
</style>

<section class="Hui-article-box">
    <div class="select_date">
        <span id="selectdata" class="">选择日期:</span>
        <div class="laydate-box">
            <input type="text" id="laydateInputs" placeholder="年-月-日">
        </div>
    </div>

    <div class="text-c search_tiaojian">
        <form action="/index/Index/search_gk" method="post">
        查询条件：
        <input type="text" id="logmin" name="logmin" value="<?php echo isset($search_data['logmin'])?$search_data['logmin']:''; ?>" class="input-text Wdate" style="width:120px;">
        -
        <input type="text" id="logmax" name="logmax" value="<?php echo isset($search_data['logmax'])?$search_data['logmax']:''; ?>" class="input-text Wdate" style="width:120px;">
        <input type="text" name="gk_name" value="<?php echo isset($search_data['gk_name'])?$search_data['gk_name']:''; ?>" id="gk_name" placeholder="顾客姓名、医生姓名、设备名称" style="width:250px" class="input-text">
        <button name="" id="search_bt" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜素</button>
        </form>
    </div>


    <?php
    if(!empty($qx[29]['p_id'])){
    ?>

    <div class="page-container" >
        <input class="btn btn-primary radius" type="button" value="文件下载" onclick="createFile()">
    </div>

    <?php
    }
    ?>
    


    <table class="table table-border table-bordered table-striped table-hover table-bg tablesorter" id="mytable">
        <thead>
            <tr class="text-c">
                <th style="width: 30%;">姓名</th>
                <th style="width: 40%;">时间</th>
                <th style="width: 30%;">项目</th>
                <!--<th style="width: 20%;">邀约</th>-->
            </tr>
        </thead>
        <tbody class="tbody">

        <?php $i=1; ?>

        <{volist name="data" id="vo"}>
        <{eq name="$vo.done" value="0"}>
            <tr>
        <{/eq}>
        <{eq name="$vo.done" value="1"}>
            <tr class="success">
        <{/eq}>
        <{eq name="$vo.freeType" value="1"}>
            <tr class="success">
        <{/eq}>

                <td ids="<{$vo.d_id}>" class="name_but"><{$vo.name}></td>
                <td><{$vo.shijian}></td>

                <td  title='<{$vo.buwei}>'><{$vo.buwei}></td>
                <!--<td><{$vo.yaoyue}></td>-->
				<!--是否是管理员-->
            </tr>
        <{/volist}>
        </tbody>
    </table>

</section>

<script type="text/javascript">
    setTimeout('set_date()',500);

    function set_date(){
        console.log($("#laydateInputs").val());
        $("#order_date").attr("value",$("#laydateInputs").val());
    }

$(function(){
    $('.device_status input').iCheck({
        checkboxClass: 'icheckbox-blue',
        radioClass: 'iradio-blue',
        increaseArea: '20%'
    });
    //多条件排序、仪器情况、排班表 切换
    $("#tab_demo").Huitab({ "tabBar":".tabBar span", "tabCon": ".tabCon", "className": "current", "tabEvent": "click", "index": 0 });

    //js限制必须要选择排序条件才能点击按钮
    $(".sub_order").on("click",function(){
        if($("input[name='order_item']").is(':checked')||$("input[name='order_id']").is(':checked')||$("input[name='order_name']").is(':checked')){
            $("#order_from").submit();
        }else{
            $.Huimodalalert('必须勾选排序条件！',2000)
        }
    });

    /*
    //通过url获取date参数
    var str=location.href;

    urldata = str.split("?");

    if(str.indexOf("?")==-1){
        //表示没有问号，即今天的数据
    }else{
        date = urldata[1];
        riqi = date.split("=")[1];
        $("#order_date").attr("value",riqi);
    }
     */

    //排序checkbox的选中状态
    $('.order_table .check-box input').iCheck({
        checkboxClass: 'icheckbox-blue',
        radioClass: 'iradio-blue',
        increaseArea: '20%'
    });



	$(".delete").on("click",function(){
        ids = $(this).attr("ids");
        $.post("/index/Index/deleteRecode",{"ids":ids},function (e) {
           if(e==1){
               $.Huimodalalert('删除成功',2000);
               window.location.reload();
           }else if(e=="deny"){
               //无权限删除
               $.Huimodalalert('无权限进行该操作',1000);
           }
        })
    });
	 //常规用法
    laydate.render({
        elem: '#laydateInputs' ,
        done: function(value, date, endDate){
            console.log(value); //得到日期生成的值，如：2017-08-18
            window.location.href="/index/Index/listdata?date="+value;
            $("#laydateInput").val(value);

        }
    });

    laydate.render({
        elem: '#logmin' ,
        done: function(value, date, endDate){
            //console.log(value); //得到日期生成的值，如：2017-08-18
           // window.location.href="/index/Index/listdata?riqi="+value;
            //$("#laydateInput").val(value);
        }
    });
    laydate.render({
        elem: '#logmax' ,
        done: function(value, date, endDate){
            //console.log(value); //得到日期生成的值，如：2017-08-18
            // window.location.href="/index/Index/listdata?riqi="+value;
            //$("#laydateInput").val(value);
        }
    });

    function strToJson(str){
        return JSON.parse(str);
    }
    function formatDateTime(timeStamp) {
        var date = new Date();
        date.setTime(timeStamp * 1000);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        //return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
        return y + '-' + m + '-' + d;
    }



    $("#mytable").tablesorter();

    $('#mytable thead').on( 'click', 'tr', function () {
        if ( $(this).hasClass('selected') ) {
            $(this).removeClass('selected');
        }
        else {
            table.$('tr.selected').removeClass('selected');
            $(this).addClass('selected');
        }
    });

    //修改
    $(".name_but").on("click",function(){
        id = $(this).attr("ids");
        //判断修改方法是否有权限操作
        $.post("/index/Index/modify",{"id":id},function(e){
            console.log(e);
            if(e=="deny"){
                $.Huimodalalert('无权限进行该操作',1000);
                return false;
            }else{
                window.location.href = "/index/Index/modify?id="+id
            }
        });

    });
    //设置已治疗
    $(".btn-secondary").on("click",function(){
        id = $(this).attr("ids");
        var obj = $(this);
        $.post("/index/Index/setDone",{"id":id},function(e){
            console.log(e);
            if(e=="success"){
                $.Huimodalalert('设置成功',1000);
                obj.removeClass("btn-secondary").addClass("disabled");
                obj.attr("value","已治疗");
                obj.parent().parent().addClass("success");
                obj.prev().removeClass("btn-warning").addClass("disabled");
            }else if(e=="deny"){
                //无权限操作
                $.Huimodalalert('无权限进行该操作',1000);
            }
        });

    });

    riqi = getQueryVariable("date");
    if(riqi){
        $("#laydateInputs").val(decodeURI(getQueryVariable("date")));
    }else{
        $("#laydateInputs").val(getNowFormatDate());
    }

});
function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}


function getQueryVariable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if(pair[0] == variable){return pair[1];}
    }
    return(false);
}

//排序部分，开关事件
$('#mySwitch').on('switch-change', function (e, data) {
    var $el = $(data.el)
        , value = data.value;
    console.log(e, $el, value);
});


function createFile(){//生成文件
    //console.log('触发');
    $.post("/index/Index/createFile",{"id":1},function(e){
        location.href='http://'+e.part;
    });
}
</script>
<{include file="Common/footer"}>